package rdd01.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Spark_Filter {
  def main(args: Array[String]): Unit = {
    val sparkConf=new SparkConf().setMaster("local[*]").setAppName("FlatMap")
    val sc=new SparkContext(sparkConf)
    val rdd:RDD[Int] = sc.makeRDD(List(1, 2, 3, 4), 2)
    //filter算子
//    var filterRDD: RDD[Int] = rdd.filter(num => num % 2 != 0)
//    filterRDD.collect().foreach(println)
     val filter:RDD[String]=sc.textFile("data/apache.log")
     filter.filter(
       line=>{
         val datas=line.split(" ")
         val time=datas(3)
         time.startsWith("17/05/2015")
       }
     ).collect().foreach(println)

    sc.stop()
  }

}
